//
//  SLMineSettingVC.swift
//  sulit-loan
//
//  Created by 王刚锋 on 2025/4/18.
//  Copyright © 2025 coolBoy. All rights reserved.
//

import UIKit
import MBProgressHUD

class SLMineSettingVC: SLBaseVC {

    @IBOutlet weak var version: UILabel!
    @IBOutlet weak var va: UIView!
    @IBOutlet weak var vb: UIView!
    @IBOutlet weak var vc: UIView!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "Setting"
        va.layer.masksToBounds = true
        va.layer.cornerRadius = 10
        
        vb.layer.masksToBounds = true
        vb.layer.cornerRadius = 10
        
        vc.layer.masksToBounds = true
        vc.layer.cornerRadius = 10
        let tapa = UITapGestureRecognizer(target: self, action: #selector(tapClick(_:)))
        vb.addGestureRecognizer(tapa)
        
        let tapb = UITapGestureRecognizer(target: self, action: #selector(tapClick(_:)))
        vc.addGestureRecognizer(tapb)
        
        self.version.text = SLTool.getVersion()
    }
    @objc private func tapClick(_ tap:UITapGestureRecognizer){
        if tap.view == self.vb{
            SLMineCancellationVC.push(page: self) {[weak self] value in
                if let ss = self {
                    ss.logout()
                }
            }
        }else if tap.view == self.vc{
            SLMineLogoff.showAlert(page: self) {[weak self] value in
                if let ss = self {
                    ss.logoff()
                }
            }
        }
    }
    private func logout(){
        SLHttpTool.AsyncReportData(path: "/satisfies/transfer", target: self) { responseCall, success, msg, code in
            if success {
                SLUserAccount.logout()
                self.navigationController?.popToRootViewController(animated: true)
                jump(url:"fon://dos.ya/entered")
                
            }
            MBProgressHUD.showSuccess(success: msg)
        }
    }
    private func logoff(){
        SLHttpTool.AsyncReportData(path: "/satisfies/occurred", target: self) { responseCall, success, msg, code in
            if success {
                SLUserAccount.logout()
                self.navigationController?.popToRootViewController(animated: true)
                jump(url:"fon://dos.ya/entered")
                
            }
            MBProgressHUD.showSuccess(success: msg)
        }
    }
}
